package teehee.Form;

/**
 * Verifies:
 *   - Weight -- No special character and that it is a floating point integer
 *               (or cast the input as a floating point integer)
 * 
 * @author  Bohan Liu
 */
public class SubmitInfoForm
{

	
	String date;
	String weight;
	String height;
	
	public SubmitInfoForm(String a, String b, String c)
	{
		date = a;
		weight = b;
		height = c;
	}
	
	
	/**
	 * Check if the enter date, weight, Height is valid
	 * @name validateForm
	 * @throws NullPointerException
	 * @return true
	 * @param String String String
	 */
	
	public boolean validForm( String d, String w, String h) throws NullPointerException
	{

		boolean isDate;
		boolean isWeight;
		isDate = this.validDate(d);
		isWeight = SubmitInfoForm.valid(w);
        //isHeight = SubmitInfoForm.validHeight(h);
		
		
		if ( (isDate == true) && (isWeight == true)) return true;
		else return false;
	}
	
	
	public boolean validDate( String d){
	/*	
		if ( d == null) return false;
		if( d.length() != 8 ) return false;
		if( d.charAt(2) != '/' && d.charAt(5) != '/') return false;
		if(!(d.substring(0,2)).matches( "[0-9]+" )) return false;
		if(!(d.substring(3,5)).matches( "[0-9]+" )) return false;
		if(!(d.substring(6,8)).matches( "[0-9]+" )) return false; */
		return true;
	}
	
	public static boolean valid( String w){
		 
		try{
			Double d = Double.parseDouble(w);
			
			if(d==0)
				return false;
			
			else
			return true;
		}
		catch(Exception e)
		{
			return false;
		}
	}
	
	
	
	
	
}
